#ifndef _RGB_THREAD_H_
#define _RGB_THREAD_H_

#include <QObject>
#include <QThread>
#include <QByteArray>
#include <QDebug>
#include "mThread/mThread.h"
#include "Effects/RGBEffect.h"
#include "Components/Effects/ControllerZone.h"

#if 0
// 构造一个线程父类,用于提供线程的控制操作
class mThread : public QThread
{
    Q_OBJECT
public:
    explicit mThread(QObject *parent = nullptr) : QThread(parent)
    {
        ;//hid = nullptr;
    }
    ~mThread()
    {
        StopThread();
    }

protected:
    virtual void run() override
    {
        /* ... here is the expensive or blocking operation ... */
        setup();
        //while(0==stop) loop();
        while(0==isexit()) loop();
        quit();
    }
    virtual void setup()
    {
        /* ... here is the expensive or blocking operation ... */
    }
    virtual void loop()
    {
        /* ... here is the expensive or blocking operation ... */
    }

public:
    static void StopThread(void) { stop = 1;}
    int isrun(void)
    {
        if((0==stop) && (1==is_run)) return 1;
        return 0;
    }
    // 线程退出标志
    int isexit(void)
    {
        return stop;
    }
    void set_run(void) { is_run = 1; }
    void set_stop(void) { is_run = 0; }

private:
//protected:
    static int stop;
    int is_run;
};
#endif
#define   MATRIX_SIZE    41
class RGB_Thread : public mThread
{
    Q_OBJECT
public:
    explicit RGB_Thread(ControllerZone &controller, QObject *parent = nullptr) : Controller(controller), mThread(parent)
    {
        Angle=0;
    }
//    ~RGB_Thread()
//    {
//        StopThread();
//    }

private:
    void AngleRadius(void);// 计算角度和半径
    void Rotation(void);  // 旋转效果
    void Spiral(void);    // 螺旋效果
    void WaterWave(void); // 水波纹效果
protected:
    virtual void loop() override;;
signals:
    void sig_fflush(void);

private:
    uint16_t Angle;
    ControllerZone &Controller;
    RGBEffect* effect;
};


#endif // _RGB_THREAD_H_
